<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
class CreateIntegralRuleTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('integral_rules', function (Blueprint $table) {
            $table->id();
            $table->string("key")->comment("积分规则中的key");
            $table->integer("value")->nullable()->comment("相应规则对应的积分或者天数");
        });

        $data = [
            [
                "key"=>"register"
            ],[
                "key"=>"sign_in"
            ],[
                "key"=>"pass_day"
            ]
        ];
        Db::table("integral_rules")->insert($data);
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('integral_rules');
    }
}
